﻿using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.Text;

namespace TomNet.Data
{
    public class OpResult<T> : IOpResult<T>
    {
        public T Data { get; set; }

        public bool Success { get; set; }

        public int StatusCode { get; set; }

        public string Msg { get; set; }

        public OpResult<T> OK(int status = 0,T data = default,string msg = "")
        {
            Success = true;
            Data = data;
            StatusCode = status;
            Msg = msg;
            return this;
        }
        public OpResult<T> HttpOK(int status = StatusCodes.Status200OK,T data = default, string msg = "")
        {
            Success = true;
            Data = data;
            StatusCode = status;
            Msg = msg;
            return this;
        }

        public OpResult<T> NotOK(int status,T data = default,string msg = "")
        {
            Success = false;
            Data = data;
            StatusCode = status;
            Msg = msg;
            return this;
        }

        public OpResult<T> HttpNotOK(int status = StatusCodes.Status400BadRequest,T data = default,string msg = "")
        {
            Success = false;
            Data = data;
            StatusCode = status;
            Msg = msg;
            return this;
        }
    }
}
